<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>分页界面</title>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/index.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/theme/theme.css"/>
</head>
<body>
<div class="wrap-container clearfix">
    <div class="column-content-detail">
        <form class="layui-form">
            <div class="search-cont clearfix" id="tool">
                <div class="operation-btn-cont">
                    <!--button开始-->
                    <button class="layui-btn layui-btn-normal layui-btn-mid" type="button" id="addBtn"><i class="iconfont marr5">&#xe65e;</i>添加</button>
                    <button class="layui-btn layui-btn-normal layui-btn-mid" type="button" id="editBtn"><i class="iconfont marr5">&#xe606;</i>编辑</button>
                    <button class="layui-btn layui-btn-normal layui-btn-mid" type="button" id="deleteBtn"><i class="iconfont marr5">&#xe6a3;</i>删除</button>
                    <!--button结束-->
                </div>
            </div>
        </form>
        <div class="layui-form" id="table-list">
            <table id="entityList" lay-filter="entityList" class="cy-list-table"></table>
        </div>
    </div>
</div>
<!--操作-->
<script type="text/html" id="entityBar">
    <a class="layui-btn layui-btn-radius layui-btn-primary layui-btn-sm layui-smbtn-green"  lay-event="edit">编辑</a>
    <button type="button" class="layui-btn layui-btn-radius layui-btn-primary layui-btn-sm layui-smbtn-red" lay-event="delete">删除</button>
</script>
<script src="${s.base}/lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="${s.base}/js/common.js" type="text/javascript" charset="utf-8"></script>
<script>
    var tableIns = null;

    function show(path) {
        layer.open({
            type: 1
            , title: false
            , closeBtn: 0
            , skin: 'layui-layer-nobg'
            , shadeClose: true
            , content: '<img src="/sysFile/showFileByPath?path=' + path + '" style="max-height:300px;max-width:100%;">'
            , scrollbar: false
        })
    }

    layui.use(['jquery', 'table', 'page', 'dialog'], function () {
        var $ = layui.jquery,
            page = layui.page,
            table = layui.table,
            dialog = layui.dialog;

        //获取分页数据
        page.initDict('base_status', function (dictData) {
            var url = "/website/websiteconfiguration/page";
            var cols = [
                {type: 'checkbox', fixed: 'left'},
                {field: 'name', title: '名称', align: 'center'},
                {field: 'phone', title: '手机号', align: 'center'},
                {field: 'telephone', title: '座机号', align: 'center'},
                {field: 'qqCode', title: 'QQ', align: 'center'},
                {
                    field: 'logo', title: 'logo', align: 'center', templet: function (d) {
                        return "<img onclick='show(\"" + d.logoPath + "\")' src='/sysFile/showFileByPath?path=" + d.logoPath + "' style='width: 30px;height: 30px;'/>";
                    }
                },
                {
                    field: 'interactPath', title: '互动二维码', align: 'center', templet: function (d) {
                        return "<img onclick='show(\"" + d.interactPath + "\")' src='/sysFile/showFileByPath?path=" + d.interactPath + "' style='width: 30px;height: 30px;'/>";
                    }
                },
                {
                    field: 'followPath', title: '关注二维码', align: 'center', templet: function (d) {
                        return "<img onclick='show(\"" + d.followPath + "\")' src='/sysFile/showFileByPath?path=" + d.followPath + "' style='width: 30px;height: 30px;'/>";
                    }
                },
                {field: 'companyAddress', title: '公司地址', align: 'center'},
                {field: 'recordNo', title: '网站备案号', align: 'center'},
                {field: 'longitude', title: '经度', align: 'center'},
                {field: 'latitude', title: '纬度', align: 'center'},
                {title: '操作', width: 170, templet: '#entityBar', align: "center"}
            ];
            tableIns = page.initDate(cols, url);
        });

        //监听行工具事件
        table.on('tool(entityList)', function (obj) {
            var layEvent = obj.event,
                data = obj.data;
            if (layEvent === 'add') {
                page.editPopup('/website/websiteconfiguration/getEdit?parentId=' + data.id, '添加');
            }
            if (layEvent === 'edit') {
                page.editPopup('/website/websiteconfiguration/getEdit?id=' + data.id, '编辑');
            }
            if (layEvent === 'delete') {
                page.delete('/website/websiteconfiguration/remove', {"id": data.id, "_method": "DELETE"}, "确定删除吗？", function () {
                    tableIns.reload();
                });
            }
        });

        //监听添加按钮事件
        $('#addBtn').bind('click', function () {
            page.editPopup('/website/websiteconfiguration/getEdit', '添加');
        });

        //监听编辑按钮事件
        $('#editBtn').bind('click', function () {
            var data = table.checkStatus('entityList').data;
            if (data.length === 0) {
                dialog.msg("请先选择对象");
                return false;
            } else if (data.length === 1) {
                page.editPopup('/website/websiteconfiguration/getEdit?id=' + data[0].id, '编辑');
            } else if (data.length > 1) {
                dialog.msg("请选择单个对象");
                return false;
            }
        });

        //监听删除按钮事件
        $('#deleteBtn').bind('click', function () {
            var data = table.checkStatus('entityList').data;
            if (data.length === 0) {
                dialog.msg("请先选择对象");
                return false;
            } else {
                var ids = [];
                for (var i = 0; i < data.length; i++) {
                    ids.push(data[i].id)
                }
                page.delete('/website/websiteconfiguration/remove', {"id": ids.join(","), "_method": "DELETE"}, "您确定要删除吗？", function () {
                    table.reload("entityList", {
                        where: {}
                    });
                });
            }
        });
    });
</script>
</body>
</html>